package com.example.tally;

import android.content.DialogInterface;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.tally.db.DBManager;

public class SettingActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
    }
    public void onClick(View v){
        switch (v.getId()){
            case R.id.setting_iv_back:
                finish();
                break;
            case R.id.setting_tv_clean:
                showDeleteDialog();
                break;
        }
    }

    private void showDeleteDialog() {
        new AlertDialog.Builder(this).setTitle("删除提示")
                .setMessage("您确要删除这条信息吗？ \n注意：删除后无法恢复，请慎重选择")
                .setNegativeButton("取消" , null)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        DBManager.deleteAllAccounttb();
                        Toast.makeText(SettingActivity.this , "删除成功" , Toast.LENGTH_SHORT).show();
                    }
                }).create().show();
    }
}